package com.abth.douyin.util;

import org.springframework.util.ResourceUtils;

import java.io.InputStream;

public class ResourceUtil {

    /**
     * 读取resources目录下的文件内容为InputStream
     * @param fileName 文件名
     * @return InputStream对象
     */
    public static InputStream getResourceAsStream(String fileName) {
        ClassLoader classLoader = ResourceUtils.class.getClassLoader();
        InputStream inputStream = classLoader.getResourceAsStream(fileName);
        if (inputStream == null) {
            throw new IllegalArgumentException("文件未找到: " + fileName);
        }
        return inputStream;
    }

}
